//
//  HQNaviCalculateResultModel.m
//  o_amap
//
//  Created by Q神 on 2021/4/12.
//

#import "HQNaviCalculateResultModel.h"

@implementation HQNaviCalculateResultModel

+ (HQNaviCalculateResultModel *)initWithAMapNaviRoute:(AMapNaviRoute *)route {
    
    HQNaviCalculateResultModel *model = [[HQNaviCalculateResultModel alloc] init];
    model.allLength = route.routeLength;
    model.allTime = route.routeTime;
    model.pathId = [NSString stringWithFormat:@"%lu", (unsigned long)route.routeUID];
    model.cost = route.routeTollCost;
    model.startPoint = [LatLngModel initWithLat:route.routeStartPoint.latitude withLng:route.routeStartPoint.longitude];
    model.endPoint = [LatLngModel initWithLat:route.routeEndPoint.latitude withLng:route.routeEndPoint.longitude];
    NSMutableArray<LatLngModel *> *coords = [NSMutableArray array];
    [route.routeCoordinates enumerateObjectsUsingBlock:^(AMapNaviPoint * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        LatLngModel *latLng = [LatLngModel initWithLat:obj.latitude withLng:obj.longitude];
        [coords addObject:latLng];
    }];
    model.coordList = coords;
    
    return model;
}

@end
